import {fileURLToPath} from 'node:url'
import path from 'node:path'
import {defineConfig} from 'vite'
import {vitepressDemo} from 'vite-plugin-vitepress-demo'
import VueTsx from '@vitejs/plugin-vue-jsx'

// 读取我们当前的根目录
const baseUrl = fileURLToPath(new URL('.', import.meta.url))


export default defineConfig({
  plugins: [
    vitepressDemo({
      glob: ["./**/demos/*.vue"] // 只检测 demos 目录下的 vue 组件
    }),
    VueTsx(),
  ],
  resolve: {
    alias: [
      {
        'find': /^jvyou-ui-bate/,
        'replacement': path.resolve(baseUrl, 'packages/jvyou-ui-bate/src'),
      },
      {
        'find': /^@jvyou-ui-bate\/utils/,
        'replacement': path.resolve(baseUrl, 'packages/utils/src'),
      },
    ]
  },
  build: {
    target: 'esnext',
  }
})
